package com.wayne.mapper;

import com.wayne.pojo.Order;
import com.wayne.pojo.User;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface IOrderMapper {

  List<Order> findAll();

  List<Order> findByCondition(Order order);

  @Results({
      @Result(property = "id",column = "id"),
      @Result(property = "orderTime", column = "order_time"),
      @Result(property = "uid", column = "uid"),
      @Result(property = "total",column = "total"),
      @Result(property = "user" ,column = "uid", javaType = User.class,one = @One(select = "com.wayne.mapper.IUserMapper.findById"))
  })
  @Select("select * from t_order")
  List<Order> findOrderAndUser();

  @Select("select * from t_order where uid = #{uid}")
  List<Order> findByUid(Integer uid);

}
